package com.service.hibernate.pojos.ServicesUses;

import java.io.Serializable;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.service.hibernate.pojos.Services;
import com.service.hibernate.pojos.Stocks;

@SuppressWarnings("serial")
@Entity
@Table(name="services_uses")
@AssociationOverrides({
	@AssociationOverride(name="pk.stock",joinColumns=@JoinColumn(name="item_id")),
	@AssociationOverride(name="pk.service",joinColumns=@JoinColumn(name="service_id"))
})
public class ServicesUses implements Serializable {
	
	private ServicesUsesId pk=new ServicesUsesId();
	private int quantity;
	
	public ServicesUses(){
	}

	@EmbeddedId
	public ServicesUsesId getPk() {
		return pk;
	}

	public void setPk(ServicesUsesId pk) {
		this.pk = pk;
	}

	@Transient
	public Stocks getStock(){
		return getPk().getStock();
	}
	
	public void setStock(Stocks stock){
		getPk().setStock(stock);
	}
	
	@Transient
	public Services getService(){
		return getPk().getService();
	}
	
	public void setService(Services service){
		getPk().setService(service);
	}
	
	@Column(name="quantity")
	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;
 
		ServicesUses that = (ServicesUses) o;
 
		if (getPk() != null ? !getPk().equals(that.getPk())
				: that.getPk() != null)
			return false;
 
		return true;
	}
 
	public int hashCode() {
		return (getPk() != null ? getPk().hashCode() : 0);
	}
}
